import {Component, OnInit, ViewEncapsulation} from '@angular/core';
import {Pagination} from '../interfaces/pagination';
import {CheckitemService} from '../services/checkitem.service';

@Component({
  selector: 'app-main-checkitem',
  templateUrl: './main-checkitem.component.html',
  styleUrls: ['./main-checkitem.component.scss'],
  encapsulation: ViewEncapsulation.None,
})
export class MainCheckitemComponent implements OnInit {
  public pagination?: Pagination;
  public dataList?: Array<any>;

  constructor(private checkitemService: CheckitemService) {
  }

  ngOnInit(): void {
    this.pagination = {
      currentPage: 1,
      pageSize: 10,
      total: 0
    };
    this.dataList = [];
  }

  findPage(queryParam: object): void {
    if (this.pagination !== undefined) {
      const param = {
        currentPage: this.pagination.currentPage,
        pageSize: this.pagination.pageSize,
        queryString: queryParam
      };
      console.log(param);
      // this.checkitemService.findPage(param).subscribe((res) => {
      //     console.log(res);
      //     if (this.pagination !== undefined) {
      //       this.pagination.total = res.data.total;
      //
      //     }
      //     this.dataList = res.data.rows;
      //   }
      // );
    }
  }

  handleCreate(): void {
  }

  handleUpdate(): void {
  }

  handleDelete(): void {
  }
}
